<template>
  <div>
    <div class="main_wrap">
      <div class="header">
        <a href="#" class="logo"
          ><img src="~@/assets/images/logo.png" alt=""
        /></a>
        <div class="copyright">
          CopyRight © 2019 深圳百秀信息技术股份有限公司<br />All Rights Reserved
        </div>
      </div>

      <div class="login_form_con">
        <div class="login_title"></div>
        <form class="login_form">
          <i class="iconfont icon-user"></i>
          <i class="iconfont icon-key"></i>
          <input
            type="text"
            class="input_txt"
            placeholder="邮箱/手机号"
            v-model="username"
          />
          <input
            type="password"
            class="input_pass"
            placeholder="密码"
            v-model="password"
          />
          <input
            type="submit"
            class="input_sub"
            value="登 录"
            @click="doLogin"
          />
        </form>
      </div>
    </div>
  </div>
</template>

<script>
import { userLogin } from "./user.js";
import { saveToken } from "../../utils/token.js";
export default {
  name: "login",
  data() {
    return {
      username: "admin",
      password: "123456",
    };
  },
  methods: {
    async doLogin() {
      let res = await userLogin(this.username, this.password);
      console.log(res);
      saveToken(res.data.token); //存 token令牌
      // 弹窗提示
      this.$alert("登陆成功", "友情提示", {
        confirmButtonText: "确定",
        callback: (action) => {
          this.$router.push({ path: "/home" }); // 跳转用户页面
        },
      });
    },
  },
};
</script>

<style>
</style>